//app.js
App({
  globalData: {
    userInfo: null,
  },
  onLaunch: function () {
    // 获取用户信息
    this.getUserInfo()
    console.log("启动小程序")
  },
  
  getUserInfo: function (cb) {
    var that = this
    wx.login({
      success: function () {
        wx.getUserInfo({
          success: function (res) {
            that.globalData.userInfo = res.userInfo
            typeof cb == "function" && cb(that.globalData.userInfo)
          }
        })
      }
    })
  },
})